package com.pulse.base.controller;

import com.pulse.base.domain.CircuitThreshold;
import com.pulse.base.service.ICircuitThresholdService;
import com.pulse.common.annotation.Log;
import com.pulse.common.core.controller.BaseController;
import com.pulse.common.core.domain.AjaxResult;
import com.pulse.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName CircuitThresholdControiller
 * @Description
 * @Author 陆帅
 * @Date 2024/9/25 15:23
 */
@RestController
@RequestMapping("/base/threshold")
public class CircuitThresholdController extends BaseController {

    @Autowired
    private ICircuitThresholdService circuitThresholdService;

    @GetMapping(value = "/{deviceNo}/{channel}")
    public AjaxResult getThreshold(@PathVariable("deviceNo") String deviceNo, @PathVariable("channel")Integer channel){
        return success(circuitThresholdService.selectThresholdByDeviceNoAndChannel(deviceNo,channel));
    }

    @Log(title = "报警阈值", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CircuitThreshold circuitThreshold)
    {
        return toAjax(circuitThresholdService.insertThreshold(circuitThreshold));
    }

    @Log(title = "报警阈值", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CircuitThreshold circuitThreshold)
    {
        return toAjax(circuitThresholdService.updateThreshold(circuitThreshold));
    }
}
